const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const { URL } = require('url')
require('dotenv').config({ path: path.resolve(__dirname, '.env.' + process.env.NODE_ENV) })

const isProd = process.env.NODE_ENV === "production"

let port = 7795;

if (process.env.WEBPACK_DEV_SERVER_URL) {
  let item = new URL(process.env.WEBPACK_DEV_SERVER_URL)
  port = item.port
}

module.exports = defineConfig({
  productionSourceMap: false,
  transpileDependencies: true,
  lintOnSave: false,
  devServer: {
    port,
  },
  publicPath: isProd ? "./" : "/",
})
